package com.example.myfirstapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Paint;
import android.os.Bundle;
import android.text.Html;
import android.widget.TextView;

public class TextViewActivity extends AppCompatActivity {
    //定义textview 属性
    private TextView mtv4;
    private TextView mtv5;
    private TextView mtv6;
    private TextView mtv7;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_text_view);
        //获取textview属性
        mtv4 = (TextView)findViewById(R.id.tv_4);
        mtv5 = (TextView)findViewById(R.id.tv_5);
        mtv6 =  (TextView)findViewById(R.id.tv_6);
        mtv7 = (TextView)findViewById(R.id.tv_7);
        //中划线,有锯齿的感觉
        mtv4.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        mtv4.getPaint().setAntiAlias(true);//去除锯齿


        //设置下划线
        mtv5.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);

        //html方式设置下划线
        mtv6.setText(Html.fromHtml("<u>天哥在奔跑</u>"));

        //跑马灯
        mtv7.setSelected(true);
    }
}
